#include "stdafx.h"
#include "RenderEntity.h"

DECLARATION( CRenderEntity )
CRenderEntity::CRenderEntity()
{
	memset(&mPosition, 0, sizeof(mPosition));
	memset(&mRotate, 0, sizeof(mRotate));
	memset(&mScale, 0, sizeof(mScale));
}

CRenderEntity::~CRenderEntity()
{

}

void CRenderEntity::SetPosition(D3DXVECTOR3 Positon)
{
	mPosition = Positon;
	mMatrix._41 = mPosition.x;
	mMatrix._42 = mPosition.y;
	mMatrix._43 = mPosition.z;
}

void CRenderEntity::SetRotate(D3DXVECTOR3 Rotate)
{

}

void CRenderEntity::SetScale(D3DXVECTOR3 Scale)
{
	mPosition = Scale;
	mMatrix._11 = mScale.x;
	mMatrix._22 = mScale.y;
	mMatrix._33 = mScale.z;
}

void CRenderEntity::AddModel(const String&name, CModel* pModel, CMaterial* pMaterial, RenderState* pRenderState)
{
	std::map<String, _RenderChunk>::iterator iter = mRenderChunkMap.find(name);
	if (iter == mRenderChunkMap.end())
	{
		mRenderChunkMap[name].mModels = pModel;
		mRenderChunkMap[name].mMaterial = *pMaterial;
		mRenderChunkMap[name].mRenderState = *pRenderState;
	}
}

void CRenderEntity::RemoveModel(const String&name)
{
	std::map<String, _RenderChunk>::iterator iter = mRenderChunkMap.find(name);
	if (iter != mRenderChunkMap.end())
	{
		_RenderChunk* pRenderChunk = &(iter->second);
		Safe_Release(pRenderChunk->mModels);

	}
}




